package triannon.client.sprites.renderer;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;

import triannon.client.settings.LevelProperties;
import triannon.client.sprites.Field;
import triannon.client.util.TMath;

public class BlockedSectorRenderer {
	public void paint(Graphics2D g, Field field, Rectangle visibleRect) {
		int rectX = TMath.toLevelCoorninates(visibleRect.x);
		int rectY = TMath.toLevelCoorninates(visibleRect.y);

		g.setColor(Color.RED);
		for (int iX = rectX; iX < rectX
				+ TMath.toLevelCoorninates(visibleRect.width) + 1; iX++) {
			for (int iY = rectY; iY < rectY
					+ TMath.toLevelCoorninates(visibleRect.height) + 1; iY++) {
				if (field.blocked(null, iX, iY)) {
					g.drawRect(TMath.toWorldCoorninates(iX),
							TMath.toWorldCoorninates(iY), LevelProperties.getGridSize(),
							LevelProperties.getGridSize());
					g.drawLine(TMath.toWorldCoorninates(iX), TMath.toWorldCoorninates(iY)
							+ LevelProperties.getGridSize(), TMath.toWorldCoorninates(iX)
							+ LevelProperties.getGridSize(), TMath.toWorldCoorninates(iY));
					g.drawLine(TMath.toWorldCoorninates(iX)
							+ LevelProperties.getGridSize(), TMath.toWorldCoorninates(iY)
							+ LevelProperties.getGridSize(), TMath.toWorldCoorninates(iX),
							TMath.toWorldCoorninates(iY));
				}
			}
		}
	}
}
